﻿#include "ConstValueNode.h"
#include "ConstValueNodeGraphicsItem.h"
ConstValueNode::ConstValueNode() : DA::DAAbstractNode()
{
    metaData().setNodePrototype("DA.ConstValue");
    metaData().setGroup(u8"common");
    metaData().setNodeName(u8"Const Value");
    addOutputKey("value");
}

ConstValueNode::~ConstValueNode()
{
}

bool ConstValueNode::exec()
{
    return true;
}

void ConstValueNode::setDisplayName(const QString& name)
{
    setProperty("display-name", name);
    auto gi = graphicsItem();
    if (gi) {
        if (auto basegi = dynamic_cast< ConstValueNodeGraphicsItem* >(gi)) {
            basegi->nodeDisplayNameChanged(name);
        }
    }
}

QString ConstValueNode::getDisplayName() const
{
    return getProperty("display-name").toString();
}

void ConstValueNode::setValue(const QVariant& v)
{
    mValue = v;
}

QVariant ConstValueNode::getValue() const
{
    return mValue;
}

DA::DAAbstractNodeGraphicsItem* ConstValueNode::createGraphicsItem()
{
    auto item = new ConstValueNodeGraphicsItem(this);
    return item;
}
